package vn.com.shoppie.activity;

import java.util.ArrayList;

import vn.com.shoppie.object.ProfileAdapter;
import vn.com.shoppie.sobject.Shop;
import vn.com.shoppie.util.SUtil;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class ProfileActivity extends Activity {
	private ListView mLvShops;
	private ArrayList<Shop> mShopData;
	private ProfileAdapter mAdapterProfile;
	
	// internal views
	TextView mTvScore;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_profile);
		mLvShops = (ListView) findViewById(R.id.lv_shops);
		mTvScore=(TextView)findViewById(R.id.tv_score);
		mTvScore.setTypeface(SUtil.getInstance().getFont(this, "digifaw.ttf"));
		
		refreshUI();
	}

	public void refreshUI() {
		mShopData=createDataSample();
		mAdapterProfile = new ProfileAdapter(this, mShopData);
		mLvShops.setAdapter(mAdapterProfile);
		
		
	}
	public void refreshBtn() {
		Button btn=(Button)findViewById(R.id.btn_like);
		btn.setBackgroundResource(R.drawable.btn_profile);
		btn=(Button)findViewById(R.id.btn_shop);
		btn.setBackgroundResource(R.drawable.btn_profile);
		btn=(Button)findViewById(R.id.btn_gift);
		btn.setBackgroundResource(R.drawable.btn_profile);
		btn=(Button)findViewById(R.id.btn_trans);
		btn.setBackgroundResource(R.drawable.btn_profile);
	}
	public void btnClicked(View v) {
		refreshBtn();
		
		switch (v.getId()) {
		
		case R.id.btn_back:
			this.finish();
			break;
		case R.id.btn_pie:
			break;
		case R.id.btn_option:
			break;
		case R.id.btn_like:
			v.setBackgroundResource(R.drawable.btn_profile_selected);
			break;
		case R.id.btn_shop:
			v.setBackgroundResource(R.drawable.btn_profile_selected);
			break;
		case R.id.btn_gift:
			v.setBackgroundResource(R.drawable.btn_profile_selected);
			break;
		case R.id.btn_trans:
			v.setBackgroundResource(R.drawable.btn_profile_selected);
			break;
		default:
			break;
		}
	}

	// create data
	public ArrayList<Shop> createDataSample() {
		ArrayList<Shop> data = new ArrayList<Shop>();
		for (int i = 0; i < 11; i++) {
			Shop item = null;
			if (i % 2 == 0) {
				String[] values={R.drawable.cocacola+"", "Cocacola" + i,"0","0","0"};
				item=new Shop(-1,values);
				item.desc="uong cocacola ngon lam"+i;
				item.discount=i*10;
				item.score=i*10;
			} else {
				String[] values={R.drawable.doraemon+"", "Cocacola" + i,"0","0","0"};
				item=new Shop(-1,values);
				item.desc="truyen tranh doraemon hay lam"+i;
				item.discount=i*10;
				item.score=i*10;
			}
			data.add(item);
		}
		return data;
	}

}
